<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>子元素浮动对父元素的影响</title>
    <style>
        .parent{
            border: 10px solid blue;
            margin: 10px;
        }
        .child{
            /* width: 100px; */
            /* width: 100%; */
            width: calc(100% - 20px);
            height: 100px;
            margin: 10px;
            background-color: red;
            float: right;
        }
        .clear{
            /* 清除浮动 */
            clear: both;
        }
        .clear2{    
            /* 子元素浮动，父元素失去子元素的支撑，
            使用 overflow: hidden使得子元素的高度继续撑起父元素 */
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div class="parent">hello</div>
    <div class="parent clear2">
        <div class="child">1</div>
        <div class="child">2</div>
        <div class="child">3</div>
        <div class="child">4</div>
    </div>
    <div class="parent clear">hello</div>
</body>
</html>